<?php
include_once("../config/config.php");

// build the menu - later this will go into the menu page
$packs=array();
function pages($ar){
	$r = "\r<ul>";
	foreach ($ar as $l) {
		$r .= "\r<li>";
		$r .= "<span><a href='".trim($l['file'])."'>";
		$r .= trim($l['list']);
		$r .= "</a></span>";
		$r .= "</li>";
	}
	$r .="\r</ul>";
	return $r;
}
function classes($ar){
	$r = "\t<ul>\n";
	foreach ($ar as $l) {
		$r .= "\t\t<li>";
		$r .= trim($l['className']);
		$r .= pages($l['files']);
		$r .= "</li>\n";
	}
	$r .="\t</ul>\n";
	return $r;
}
function makePackList($packs){
	$myL = "<ul>\n";
	foreach ($packs as $packval) {
		$myL .= "\t<li>";
		//we have pack & file
		$pk = $packval["pack"];
		$fl = $packval["class"];

		$myL .= $pk;
		$myL .= classes($fl);
		$myL .= "</li>\n";
	}
	$myL .= "</ul>";
	return $myL;
}

// include all the menu files
include_once("dyn.menu.php");

//build the menu
echo makePackList($packs);
	?>

	<script>
	$('li:has(ul)')
	.click(function(event){
		if (this == event.target) {
			if ($(this).children().is(':hidden')) {
				$(this)
				.css('list-style-image','url(<?php echo HTTP_BASE."medias/admin_images/"?>minus.gif)')
				.children().show(250);
			} else {
				$(this)
				.css('list-style-image','url(<?php echo HTTP_BASE."medias/admin_images/"?>plus.gif)')
				.children().hide(250);
			}
		}
		return false;
	}).css('cursor','pointer').click();

	$('li:not(:has(ul))').css({
		cursor: 'default',
		'list-style-image':'none'
	});
	$('li span a').click(function(event){

		//window.frames.ca.document.location.href="/";
		window.frames.ca.document.location.href=($(this).attr("href"));
	});

	</script>